using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Reflection;

namespace process
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr SetParent(IntPtr child, IntPtr newParent);
        [DllImport("user32.dll")]
        static extern bool ExitWindowsEx(uint uFlags, uint dwReason);

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Process.Start("C:\\Program Files\\Windows Media Player\\wmplayer.exe");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Process _process = new Process();
            ProcessStartInfo info = new ProcessStartInfo();
            info.FileName = "Notepad.exe";
            //info.FileName = "mspaint";
            info.WindowStyle = ProcessWindowStyle.Normal;
            _process = Process.Start(info);
            //System.Threading.Thread.Sleep(100);
            SetParent(_process.MainWindowHandle, this.Handle);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form f = new Form();
            f.Show();
            f.BackColor = Color.Red;
            Panel panel1 = new Panel();
            System.Threading.Thread.Sleep(1000);
            SetParent(f.Handle, panel1.Handle);  
        }
        int i = 0;

        private void button4_Click(object sender, EventArgs e)
        {
            Process.Start("http://google.com/");
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //ExitWindowsEx(ExitWindows.LogOff, ShutdownReason.MajorOther & ShutdownReason.MinorOther); 
            ExitWindowsEx(1, 0); 
        }

    }
}